home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / dbbrowser / dbbrowser.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-22  |  3.4 KB  |  139 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. /* 
  20.  * dbbrowser 
  21.  * 0.08 26th sept 97  by Thomas NOEL <thomas@minet.net> 
  22.  */
  23.  
  24. /*
  25.  * This plugin gives you the list of available procedure, with the
  26.  * name, description and parameters for each procedure.
  27.  * You can do regexp search (by name and by description)
  28.  * Useful for scripts development.
  29.  *
  30.  * NOTE :
  31.  * this is only a exercice for me (my first "plug-in" (extension))
  32.  * so it's very (very) dirty. 
  33.  * Btw, hope it gives you some ideas about gimp possibilities.
  34.  *
  35.  * The core of the plugin is not here. See dbbrowser_utils (shared
  36.  * with script-fu-console).
  37.  *
  38.  * TODO
  39.  * - bug fixes... (my method : rewrite from scratch :)
  40.  */
  41.  
  42. #include "config.h"
  43.  
  44. #include <stdlib.h>
  45. #include <stdio.h>
  46.  
  47. #include <gtk/gtk.h>
  48.  
  49. #include <libgimp/gimp.h>
  50. #include <libgimp/gimpui.h>
  51.  
  52. #include "dbbrowser_utils.h"
  53.  
  54. #include "libgimp/stdplugins-intl.h"
  55.  
  56.  
  57. static void   query (void);
  58. static void   run   (gchar     *name,
  59.              gint      nparams,
  60.              GimpParam *param,
  61.              gint      *nreturn_vals,
  62.              GimpParam **return_vals);
  63.  
  64. GimpPlugInInfo PLUG_IN_INFO =
  65. {
  66.   NULL,  /* init_proc  */
  67.   NULL,  /* quit_proc  */
  68.   query, /* query_proc */
  69.   run,   /* run_proc   */
  70. };
  71.  
  72.  
  73. MAIN ()
  74.  
  75. static void
  76. query (void)
  77. {
  78.   static GimpParamDef args[] =
  79.   {
  80.     { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
  81.   };
  82.   static gint nargs = sizeof (args) / sizeof (args[0]);
  83.  
  84.   gimp_install_procedure ("extension_db_browser",
  85.                           "List available procedures in the PDB",
  86.                           "",
  87.                           "Thomas Noel",
  88.                           "Thomas Noel",
  89.                           "23th june 1997",
  90.                           N_("<Toolbox>/Xtns/DB Browser..."),
  91.               "",
  92.                           GIMP_EXTENSION,
  93.               nargs, 0,
  94.                           args, NULL);
  95. }
  96.  
  97. static void
  98. run (gchar      *name,
  99.      gint       nparams,
  100.      GimpParam  *param,
  101.      gint       *nreturn_vals,
  102.      GimpParam  **return_vals)
  103. {
  104.   static GimpParam values[1];
  105.   GimpRunModeType run_mode;
  106.  
  107.   run_mode = param[0].data.d_int32;
  108.  
  109.   *nreturn_vals = 1;
  110.   *return_vals  = values;
  111.   values[0].type          = GIMP_PDB_STATUS;
  112.   values[0].data.d_status = GIMP_PDB_SUCCESS;
  113.  
  114.   switch (run_mode)
  115.     {
  116.     case GIMP_RUN_INTERACTIVE: 
  117.       {
  118.     INIT_I18N_UI(); 
  119.  
  120.     gimp_ui_init ("dbbrowser", FALSE);
  121.  
  122.     gtk_quit_add_destroy (1, (GtkObject *) gimp_db_browser (NULL));
  123.  
  124.     gtk_main ();
  125.     gdk_flush ();
  126.       }
  127.       break;
  128.       
  129.     case GIMP_RUN_WITH_LAST_VALS:
  130.     case GIMP_RUN_NONINTERACTIVE:
  131.       g_warning ("dbbrowser allows only interactive invocation");
  132.       values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
  133.       break;
  134.  
  135.     default:
  136.       break;
  137.     }  
  138. }
  139.